package com.wang.controller;

import com.wang.pojo.TbScheme;
import com.wang.pojo.TbSickVo;
import com.wang.pojo.TbSickness;
import com.wang.service.TbSchemeService;
import com.wang.service.TbSicknessService;
import com.wang.utills.R;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
//@CrossOrigin(origins = "*", allowedHeaders = "*")
@RestController
@RequestMapping("case")
public class TbschemeController {


    @Resource
    private TbSchemeService tbSchemeService;    //方案sevice
    @Resource
    private TbSicknessService tbSicknessService; //疾病sevice

    /*
    * 查看方案
    * */

    @RequestMapping("/schemelist")
    public R schemelist(){
        return  this.tbSchemeService.schemelist();
    }
    /*
    * 全局添加方案
    * */
    @RequestMapping("/addnewscheme")
    public R addnewone(@RequestBody TbScheme tbScheme){

        return  this.tbSchemeService.addnewone(tbScheme);
    }

    /*
    * 删除方案
    * */
    @RequestMapping("/delscheme/{sid}")
    public R delScheme( Integer sid){

        return  this.tbSchemeService.delScheme(sid);
    }

    //上面哪两个是有要求的不能单查






    /*
    * 展示疾病列表
    * */
    @RequestMapping("/tbSicknesslist")
    public R tbSicknesslist(){
        return  this.tbSicknessService.tbSicknesslist();
    }
    /*
     * 疾病添加
     * */
    @RequestMapping("/tbSicknessadd")
    public R tbSicknessadd(@RequestBody TbSickness tbSickness){
        return  this.tbSicknessService.tbSicknessadd(tbSickness);
    }

    /*
     * 疾病修改
     * */
    @RequestMapping("/tbSicknessupda")
    public R tbSicknessupda(@RequestBody TbSickness tbSickness){
        return  this.tbSicknessService.tbSicknessupda(tbSickness);
    }



    /*
     * 疾病对应的方案
     * */
    @RequestMapping("/schemebysid")
    public R schemebysid(Integer sid){
        return  this.tbSicknessService.schemebysid(sid);
    }

    /*
     * uni疾病对应的方案
     * */
    @RequestMapping("/unischemebysid")
    public R unischemebysid(@RequestBody TbSickVo tbSickVo){
        return  this.tbSicknessService.schemebysid(tbSickVo.getSid());
    }




    /*
     * 疾病删除
     * */
    @RequestMapping("/tbSicknessdel/{sid}")
    public R tbSicknessdel(@PathVariable Integer sid){
        return  this.tbSicknessService.tbSicknessdel(sid);
    }


   /* @XxlJob("ma")
    public ReturnT<String> demoJobHandler(String param) throws Exception {
        XxlJobLogger.log("XXL-JOB, Hello World.");

        for (int i = 0; i < 5; i++) {
            XxlJobLogger.log("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
        return ReturnT.SUCCESS;
    }
*/
}
